package com.konke.sdslibrary.factroy;

import com.konke.sdslibrary.event.AirSwitchManagerStatusEvent;
import com.konke.sdslibrary.event.AirSwitchStatusEvent;
import com.konke.sdslibrary.event.AlarmStatusEvent;
import com.konke.sdslibrary.event.AlertorStatusEvent;
import com.konke.sdslibrary.event.BoolSensorEvent;
import com.konke.sdslibrary.event.CcuInfoChangedEvent;
import com.konke.sdslibrary.event.CentralAcGwStatusEvent;
import com.konke.sdslibrary.event.CentralAcIndoorStatusEvent;
import com.konke.sdslibrary.event.ChopinFreshAirStateEvent;
import com.konke.sdslibrary.event.CnwiseMusicStatusEvent;
import com.konke.sdslibrary.event.CodedLockAlarmChangePushEvent;
import com.konke.sdslibrary.event.CodedLockReadCardPushChangeEvent;
import com.konke.sdslibrary.event.CodedLockStatusEvent;
import com.konke.sdslibrary.event.CodelibCreateResultEvent;
import com.konke.sdslibrary.event.CodelibUploadResultEvent;
import com.konke.sdslibrary.event.DaikinIndoorStatusEvent;
import com.konke.sdslibrary.event.DetectDevPowerResultEvent;
import com.konke.sdslibrary.event.DeviceAppArgsChangedEvent;
import com.konke.sdslibrary.event.DeviceSwitchEvent;
import com.konke.sdslibrary.event.DeviceWaterSwitchEvent;
import com.konke.sdslibrary.event.DimmerStatusEvent;
import com.konke.sdslibrary.event.DoorContactEvent;
import com.konke.sdslibrary.event.DooyaOptPushEvent;
import com.konke.sdslibrary.event.DooyaStatusEvent;
import com.konke.sdslibrary.event.DriveAirerStateEvent;
import com.konke.sdslibrary.event.ExtSocketSwitchEvent;
import com.konke.sdslibrary.event.FancoilConfigArgPushEvent;
import com.konke.sdslibrary.event.FancoilStateEvent;
import com.konke.sdslibrary.event.FloorHeatingStateEvent;
import com.konke.sdslibrary.event.FloorheatingConfigArgPushEvent;
import com.konke.sdslibrary.event.FloorheatingDevStatusEvent;
import com.konke.sdslibrary.event.FloorheatingManagerStatusEvent;
import com.konke.sdslibrary.event.FreshAirConfigArgPushEvent;
import com.konke.sdslibrary.event.FreshAirDevStatusEvent;
import com.konke.sdslibrary.event.FreshAirManagerStatusEvent;
import com.konke.sdslibrary.event.FreshAirStateEvent;
import com.konke.sdslibrary.event.GwUpgradResultEvent;
import com.konke.sdslibrary.event.HostArmingChangedEvent;
import com.konke.sdslibrary.event.HostNewDeviceEvent;
import com.konke.sdslibrary.event.IllumSensorEvent;
import com.konke.sdslibrary.event.InfraredRecEvent;
import com.konke.sdslibrary.event.InfraredSendEvent;
import com.konke.sdslibrary.event.KSocketStatusEvent;
import com.konke.sdslibrary.event.KitInstallEvent;
import com.konke.sdslibrary.event.KlightStatusEvent;
import com.konke.sdslibrary.event.KonkeAircleanerStatusEvent;
import com.konke.sdslibrary.event.KonkeHumidifierStatusEvent;
import com.konke.sdslibrary.event.KonkeLockRemoteOpenDisablePushEvent;
import com.konke.sdslibrary.event.KonkeLockStatusEvent;
import com.konke.sdslibrary.event.KonkeLockSwitchPushEvent;
import com.konke.sdslibrary.event.KonkeLockUserOpenPushEvent;
import com.konke.sdslibrary.event.Lock800StatusEvent;
import com.konke.sdslibrary.event.MatchCodelibResultEvent;
import com.konke.sdslibrary.event.MotorOptEvent;
import com.konke.sdslibrary.event.NumSensorEvent;
import com.konke.sdslibrary.event.RFLearnRecEvent;
import com.konke.sdslibrary.event.RoomStatusChangedEvent;
import com.konke.sdslibrary.event.ShortcutPanelEvent;
import com.konke.sdslibrary.event.ShortcutPanelPowerEvent;
import com.konke.sdslibrary.event.SmartSwitchResultEvent;
import com.konke.sdslibrary.event.SmartSwitchStatusEvent;
import com.konke.sdslibrary.event.SosButtonEvent;
import com.konke.sdslibrary.event.YaleLockIndoorForeceLockPushEvent;
import com.konke.sdslibrary.event.YouzhuanMusicControllerStatusEvent;
import com.konke.sdslibrary.event.ZigbeeDevIdentifyEvent;
import com.konke.sdslibrary.event.ZigbeeDeviceJoinChangeEvent;
import com.konke.sdslibrary.event.ZigbeeDeviceReplaceEvent;
import com.konke.sdslibrary.event.ZigbeeDevsHwInfoPushEvent;
import com.konke.sdslibrary.model.UniformDeviceType;
import com.sds.sdk.android.sh.common.SHDeviceSubType;
import com.sds.sdk.android.sh.common.SHDeviceType;
import com.sds.sdk.android.sh.model.AlarmNotifyEvent;
import com.sds.sdk.android.sh.model.ArmingStateChangedEvent;
import com.sds.sdk.android.sh.model.BoolSensorActivedEvent;
import com.sds.sdk.android.sh.model.CentralAcGwStatus;
import com.sds.sdk.android.sh.model.CentralAcIndoorunitStatus;
import com.sds.sdk.android.sh.model.CnwiseMusicControllerStatus;
import com.sds.sdk.android.sh.model.CodeLibUploadResultPushEvent;
import com.sds.sdk.android.sh.model.CodedLockAlarmPushEvent;
import com.sds.sdk.android.sh.model.CodedLockReadCardPushEvent;
import com.sds.sdk.android.sh.model.ControllerSmartSwitchPushEvent;
import com.sds.sdk.android.sh.model.CreateNewCodeLibPushEvent;
import com.sds.sdk.android.sh.model.DaikinIndoorunitStatus;
import com.sds.sdk.android.sh.model.DetectDevPowerResultPushEvent;
import com.sds.sdk.android.sh.model.DeviceAppArgsChangedPushEvent;
import com.sds.sdk.android.sh.model.DeviceOnlineState;
import com.sds.sdk.android.sh.model.DeviceStatusChangedPushEvent;
import com.sds.sdk.android.sh.model.DooyaOptEvent;
import com.sds.sdk.android.sh.model.FancoilConfigArgEvent;
import com.sds.sdk.android.sh.model.FloorheatingConfigArgEvent;
import com.sds.sdk.android.sh.model.FloorheatingDevTempEvent;
import com.sds.sdk.android.sh.model.FreshAirConfigArgEvent;
import com.sds.sdk.android.sh.model.GetZigbeeDevsHwInfoPushEvent;
import com.sds.sdk.android.sh.model.GwUpgradeResultPushEvent;
import com.sds.sdk.android.sh.model.IdentifyPushEvent;
import com.sds.sdk.android.sh.model.InfraredPushEvent;
import com.sds.sdk.android.sh.model.KitInstallStatusPushEvent;
import com.sds.sdk.android.sh.model.KonkeAircleanerStatus;
import com.sds.sdk.android.sh.model.KonkeHumidifierStatus;
import com.sds.sdk.android.sh.model.KonkeLightStatus;
import com.sds.sdk.android.sh.model.KonkeSocketStatus;
import com.sds.sdk.android.sh.model.LockRemoteOpenDisableEvent;
import com.sds.sdk.android.sh.model.LockSwitchPushEvent;
import com.sds.sdk.android.sh.model.MatchCloudCodelibResultPushEvent;
import com.sds.sdk.android.sh.model.MatchCodeLibPushEvent;
import com.sds.sdk.android.sh.model.OpenLockUserPushEvent;
import com.sds.sdk.android.sh.model.RFLearnPushEvent;
import com.sds.sdk.android.sh.model.RoomStateChangedEvent;
import com.sds.sdk.android.sh.model.ShortcutPanelActivedEvent;
import com.sds.sdk.android.sh.model.SmartSwitchPushEvent;
import com.sds.sdk.android.sh.model.YaleLockIndoorForceLockEvent;
import com.sds.sdk.android.sh.model.YouzhuanMusicControllerStatus;
import com.sds.sdk.android.sh.model.ZigbeeAirSwitchStatus;
import com.sds.sdk.android.sh.model.ZigbeeAlertorStatus;
import com.sds.sdk.android.sh.model.ZigbeeBoolSensorStatus;
import com.sds.sdk.android.sh.model.ZigbeeChopinFreshAirStatus;
import com.sds.sdk.android.sh.model.ZigbeeCodeLockStatus;
import com.sds.sdk.android.sh.model.ZigbeeDeviceJoinEvent;
import com.sds.sdk.android.sh.model.ZigbeeDeviceStatus;
import com.sds.sdk.android.sh.model.ZigbeeDimmerStatus;
import com.sds.sdk.android.sh.model.ZigbeeDooYaStatus;
import com.sds.sdk.android.sh.model.ZigbeeDoorContactStatus;
import com.sds.sdk.android.sh.model.ZigbeeDriveAirerStatus;
import com.sds.sdk.android.sh.model.ZigbeeExtensionSocketStatus;
import com.sds.sdk.android.sh.model.ZigbeeFanCoilStatus;
import com.sds.sdk.android.sh.model.ZigbeeFloorHeatingDevStatus;
import com.sds.sdk.android.sh.model.ZigbeeFloorHeatingStatus;
import com.sds.sdk.android.sh.model.ZigbeeFreshAirDevStatus;
import com.sds.sdk.android.sh.model.ZigbeeFreshAirStatus;
import com.sds.sdk.android.sh.model.ZigbeeIllumSensorStatus;
import com.sds.sdk.android.sh.model.ZigbeeInfraredStatus;
import com.sds.sdk.android.sh.model.ZigbeeKonkeLockStatus;
import com.sds.sdk.android.sh.model.ZigbeeKonkeSocketStatus;
import com.sds.sdk.android.sh.model.ZigbeeLock800Status;
import com.sds.sdk.android.sh.model.ZigbeeMotorStatus;
import com.sds.sdk.android.sh.model.ZigbeeNodeReplacePushEvent;
import com.sds.sdk.android.sh.model.ZigbeeNumSensorStatus;
import com.sds.sdk.android.sh.model.ZigbeeOutletStatus;
import com.sds.sdk.android.sh.model.ZigbeeShortcutPanelStatus;
import com.sds.sdk.android.sh.model.ZigbeeSosButtonStatus;
import com.sds.sdk.android.sh.model.ZigbeeSwitchStatus;
import com.sds.sdk.android.sh.model.ZigbeeWaterValueStatus;
import com.zsj.comminlibrary.util.log.XLog;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by L on 2016/6/29.
 */
final class HostEventDispatcher {

    static void dispatchDeviceStatusChangedPushEvent(DeviceStatusChangedPushEvent statusChangedPushEvent, String ccuId) {

        UniformDeviceType deviceType = UniformDeviceType.transform(statusChangedPushEvent.getDevType(), statusChangedPushEvent.getDevSubType());

        if (statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_LIGHT) {
            DeviceSwitchEvent switchEvent = new DeviceSwitchEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            switchEvent.setDeviceType(deviceType);
            ZigbeeSwitchStatus zigbeeSwitchStatus = (ZigbeeSwitchStatus) statusChangedPushEvent.getStatus();
            if (zigbeeSwitchStatus != null) {
                switchEvent.setOn(zigbeeSwitchStatus.isOn());
            }
            switchEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(switchEvent);
        }else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_WaterValueSwitch) {
            DeviceWaterSwitchEvent switchEvent = new DeviceWaterSwitchEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            switchEvent.setDeviceType(deviceType);
            ZigbeeWaterValueStatus zigbeeSwitchStatus = (ZigbeeWaterValueStatus) statusChangedPushEvent.getStatus();
            if (zigbeeSwitchStatus != null) {
                switchEvent.setOn(zigbeeSwitchStatus.isOn());
            }
            switchEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(switchEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_Dimmer) {
            DimmerStatusEvent switchEvent = new DimmerStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            switchEvent.setDeviceType(deviceType);
            ZigbeeDimmerStatus zigbeeDimmerStatus = (ZigbeeDimmerStatus) statusChangedPushEvent.getStatus();
            if (zigbeeDimmerStatus != null) {
                switchEvent.setStatus(zigbeeDimmerStatus);
            }
            switchEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(switchEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_Infrared || statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_InfraredCodeLib) {
            InfraredSendEvent infraredSendEvent = new InfraredSendEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            infraredSendEvent.setDeviceType(deviceType);
            ZigbeeInfraredStatus status = (ZigbeeInfraredStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                infraredSendEvent.setCode(status.getInfraredCodeId());
            }
            infraredSendEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(infraredSendEvent);
        } else if (statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_SOCKET ||
                statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_Socket10A ||
                statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_Socket16A) {
            DeviceSwitchEvent switchEvent = new DeviceSwitchEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            switchEvent.setDeviceType(deviceType);
            ZigbeeOutletStatus zigbeeOutletStatus = (ZigbeeOutletStatus) statusChangedPushEvent.getStatus();
            if (zigbeeOutletStatus != null) {
                switchEvent.setOn(zigbeeOutletStatus.isOn());
                switchEvent.setLoad(zigbeeOutletStatus.isLoad());
            }
            switchEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(switchEvent);
        } else if (statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_KonkeSocket) {
            DeviceSwitchEvent switchEvent = new DeviceSwitchEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            switchEvent.setDeviceType(deviceType);
            ZigbeeKonkeSocketStatus zigbeeOutletStatus = (ZigbeeKonkeSocketStatus) statusChangedPushEvent.getStatus();
            if (zigbeeOutletStatus != null) {
                switchEvent.setOn(zigbeeOutletStatus.isOn());
                switchEvent.setLightOn(zigbeeOutletStatus.isLightOn());
                switchEvent.setLoad(zigbeeOutletStatus.isLoad());
            }
            switchEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(switchEvent);
        } else if (statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_ExtensionSocket) {
            ExtSocketSwitchEvent switchEvent = new ExtSocketSwitchEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            switchEvent.setDeviceType(deviceType);
            ZigbeeExtensionSocketStatus zigbeeOutletStatus = (ZigbeeExtensionSocketStatus) statusChangedPushEvent.getStatus();
            if (zigbeeOutletStatus != null) {
                switchEvent.setAllOn(zigbeeOutletStatus.isOn());
                if (zigbeeOutletStatus.getMultiSockets() != null) {
                    boolean[] socketsOn = new boolean[zigbeeOutletStatus.getMultiSockets().size()];
                    for (int i = 0; i < zigbeeOutletStatus.getMultiSockets().size(); i++) {
                        socketsOn[i] = zigbeeOutletStatus.getMultiSockets().get(i).isOn();
                    }
                    switchEvent.setSocketsOn(socketsOn);
                }
            }
            switchEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(switchEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_DriveAirer) {
            ZigbeeDriveAirerStatus status = (ZigbeeDriveAirerStatus) statusChangedPushEvent.getStatus();
            DriveAirerStateEvent event = new DriveAirerStateEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId(), status);
            event.setDeviceType(deviceType);
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FloorHeating) {
            ZigbeeFloorHeatingStatus status = (ZigbeeFloorHeatingStatus) statusChangedPushEvent.getStatus();
            FloorHeatingStateEvent event = new FloorHeatingStateEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId(), status);
            event.setDeviceType(deviceType);
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FreshAir) {
            ZigbeeFreshAirStatus status = (ZigbeeFreshAirStatus) statusChangedPushEvent.getStatus();
            FreshAirStateEvent event = new FreshAirStateEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId(), status);
            event.setDeviceType(deviceType);
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType()== SHDeviceType.ZIGBEE_ChopinFreshAir){
            ZigbeeChopinFreshAirStatus status = (ZigbeeChopinFreshAirStatus) statusChangedPushEvent.getStatus();
            ChopinFreshAirStateEvent event = new ChopinFreshAirStateEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId(), status);
            event.setDeviceType(deviceType);
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        }else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_SOSButton) {
            ZigbeeSosButtonStatus status = (ZigbeeSosButtonStatus) statusChangedPushEvent.getStatus();
            SosButtonEvent event = new SosButtonEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setDeviceType(deviceType);
            if (status != null) {
                event.setBattery(status.getBattery());
                event.setNormal(!status.isOn());
                event.setLowPower(status.isLowPower());
            }
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FanCoil) {
            ZigbeeFanCoilStatus status = (ZigbeeFanCoilStatus) statusChangedPushEvent.getStatus();
            FancoilStateEvent event = new FancoilStateEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId(), status);
            event.setDeviceType(deviceType);
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_Motor) {
            if (statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_DooYa) {
                DooyaStatusEvent motorOptEvent = new DooyaStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
                motorOptEvent.setDeviceType(deviceType);
                ZigbeeDooYaStatus status = (ZigbeeDooYaStatus) statusChangedPushEvent.getStatus();
                if (status != null) {
                    motorOptEvent.setState(status.getSwitchStatus().name());
                    motorOptEvent.setMotorPos(status.getMotorPos());
                    motorOptEvent.setRouteCfg(status.isRouteCfg());
                }
                motorOptEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
                EventBus.getDefault().post(motorOptEvent);
            } else {
                MotorOptEvent motorOptEvent = new MotorOptEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
                motorOptEvent.setDeviceType(deviceType);
                ZigbeeMotorStatus status = (ZigbeeMotorStatus) statusChangedPushEvent.getStatus();
                if (status != null) {
                    motorOptEvent.setState(status.getStatus().name());
                }
                motorOptEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
                EventBus.getDefault().post(motorOptEvent);
            }
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_BoolSensor) {
            BoolSensorEvent event = new BoolSensorEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setDeviceType(deviceType);
            ZigbeeBoolSensorStatus status = (ZigbeeBoolSensorStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                statusChangedPushEvent.getDevSubType();
                UniformDeviceType uniformDeviceType = UniformDeviceType.transform(statusChangedPushEvent.getDevType(), statusChangedPushEvent.getDevSubType());
                event.setBattery(status.getBattery());
                event.setDismantle(status.isDismantle());
                event.setLowPower(status.isLowPower());
                event.setNormal(status.isNormal());
                event.setProbeFalloff(status.isProbeFalloff());
                event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
                event.setUniformDeviceType(uniformDeviceType);
            }
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_DoorContact) {
            DoorContactEvent event = new DoorContactEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setDeviceType(deviceType);
            ZigbeeDoorContactStatus status = (ZigbeeDoorContactStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setOn(status.isOn());
                event.setPower(status.getPower());
                event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            }
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_ShortcutPanel) {
            ZigbeeShortcutPanelStatus status = (ZigbeeShortcutPanelStatus) statusChangedPushEvent.getStatus();
            ShortcutPanelPowerEvent event = new ShortcutPanelPowerEvent(ccuId, statusChangedPushEvent.getId(), status.getPower());
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_KonkeLock) {
            KonkeLockStatusEvent statusEvent = new KonkeLockStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            statusEvent.setDeviceType(deviceType);
            ZigbeeKonkeLockStatus status = (ZigbeeKonkeLockStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                statusEvent.setOn(status.isOn());
                statusEvent.setDateTime(status.getDateTime());
                statusEvent.setPower(status.getPower());
                statusEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            }
            EventBus.getDefault().post(statusEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_CodedLock) {
            CodedLockStatusEvent statusEvent = new CodedLockStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            statusEvent.setDeviceType(deviceType);
            ZigbeeCodeLockStatus status = (ZigbeeCodeLockStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                statusEvent.setPower(status.getPower());
                statusEvent.setCardCount(status.getCardUserCount());
                statusEvent.setFingerCount(status.getFingerUserCount());
                statusEvent.setKeyCount(status.getKeyUserCount());
                statusEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            }
            EventBus.getDefault().post(statusEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_Lock800) {
            Lock800StatusEvent statusEvent = new Lock800StatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            statusEvent.setDeviceType(deviceType);
            ZigbeeLock800Status status = (ZigbeeLock800Status) statusChangedPushEvent.getStatus();
            if (status != null) {
                statusEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
                statusEvent.setOn(status.isOn());
            }
            EventBus.getDefault().post(statusEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_NumSensor) {
            NumSensorEvent statusEvent;
            if (statusChangedPushEvent.getDevSubType() == SHDeviceSubType.ZIGBEE_IllumSensor) {
                ZigbeeIllumSensorStatus status = (ZigbeeIllumSensorStatus) statusChangedPushEvent.getStatus();
                statusEvent = new IllumSensorEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId(), status.getGrade());
                statusEvent.setNum(status.getNum());
            } else {
                statusEvent = new NumSensorEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
                ZigbeeNumSensorStatus status = (ZigbeeNumSensorStatus) statusChangedPushEvent.getStatus();
                statusEvent.setNum(status.getNum());
            }
            statusEvent.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            statusEvent.setDeviceType(deviceType);
            EventBus.getDefault().post(statusEvent);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_Alertor) {
            AlertorStatusEvent event = new AlertorStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            ZigbeeAlertorStatus status = (ZigbeeAlertorStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setAlarm(status.isAlarm());
                event.setBattery(status.getBattery());
                event.setSound(status.getSound());
                event.setPower(status.getPower());
                event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            }
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_KonkeSocket) {
            KSocketStatusEvent event = new KSocketStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            KonkeSocketStatus status = (KonkeSocketStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setSwitchOn(status.isSocketOn());
                event.setUsbOn(status.isUsbOn());
                event.setLightOn(status.isLightOn());
                event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            }
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_KonkeLight) {
            KlightStatusEvent event = new KlightStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            KonkeLightStatus status = (KonkeLightStatus) statusChangedPushEvent.getStatus();
            event.setStatus(status);
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_KonkeHumidifier) {
            KonkeHumidifierStatusEvent event = new KonkeHumidifierStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            KonkeHumidifierStatus status = (KonkeHumidifierStatus) statusChangedPushEvent.getStatus();
            event.setStatus(status);
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_KonkeAircleaner) {
            KonkeAircleanerStatusEvent event = new KonkeAircleanerStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            KonkeAircleanerStatus status = (KonkeAircleanerStatus) statusChangedPushEvent.getStatus();
            event.setStatus(status);
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_CnwiseMusicController) {
            CnwiseMusicStatusEvent event = new CnwiseMusicStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            CnwiseMusicControllerStatus status = (CnwiseMusicControllerStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setStatus(status);
            }
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_DaikinIndoorUnit) {
            DaikinIndoorStatusEvent event = new DaikinIndoorStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            DaikinIndoorunitStatus status = (DaikinIndoorunitStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setStatus(status);
            }
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_CENTRAL_AC_IndoorUnit) {
            CentralAcIndoorStatusEvent event = new CentralAcIndoorStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            CentralAcIndoorunitStatus status = (CentralAcIndoorunitStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setStatus(status);
            }
            event.setDeviceType(deviceType);
            event.setOnlineState(((CentralAcIndoorunitStatus) statusChangedPushEvent.getStatus()).isOnline() ? DeviceOnlineState.ONLINE : DeviceOnlineState.OFFLINE);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_CENTRAL_AC_Gateway) {
            CentralAcGwStatusEvent event = new CentralAcGwStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            CentralAcGwStatus status = (CentralAcGwStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setStatus(status);
            }
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setDeviceType(deviceType);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_AirSwitch) {
            AirSwitchStatusEvent event = new AirSwitchStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            ZigbeeAirSwitchStatus status = (ZigbeeAirSwitchStatus) statusChangedPushEvent.getStatus();
            if (status != null) {
                event.setOn(status.isOn());
                event.setLoadAlarm(status.isLoadAlarm());
                event.setTemperatureAlarm(status.isTemperatureAlarm());
            }
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setDeviceType(UniformDeviceType.ZIGBEE_AirSwitch);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_AirSwitchManager) {
            AirSwitchManagerStatusEvent event = new AirSwitchManagerStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setDeviceType(UniformDeviceType.ZIGBEE_AirSwitchManager);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.NET_YouzhuanMusicController) {
            YouzhuanMusicControllerStatusEvent event = new YouzhuanMusicControllerStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setOnline(((YouzhuanMusicControllerStatus) statusChangedPushEvent.getStatus()).isOnline());
            event.setStatus((YouzhuanMusicControllerStatus) statusChangedPushEvent.getStatus());
            event.setDeviceType(UniformDeviceType.NET_YouzhuanMusicController);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FloorHeatingManager) {
            FloorheatingManagerStatusEvent event = new FloorheatingManagerStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setDeviceType(UniformDeviceType.ZIGBEE_FloorHeatingManager);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FloorHeatingDev) {
            FloorheatingDevStatusEvent event = new FloorheatingDevStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setOn(((ZigbeeFloorHeatingDevStatus) statusChangedPushEvent.getStatus()).isOn());
            event.setLock(((ZigbeeFloorHeatingDevStatus) statusChangedPushEvent.getStatus()).isLock());
            event.setSetTemp(((ZigbeeFloorHeatingDevStatus) statusChangedPushEvent.getStatus()).getSettingTemperature());
            event.setCutTemp(((ZigbeeFloorHeatingDevStatus) statusChangedPushEvent.getStatus()).getCurrentTemperature());
            event.setDeviceType(UniformDeviceType.ZIGBEE_FloorHeatingDev);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FreshAirManager) {
            FreshAirManagerStatusEvent event = new FreshAirManagerStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setDeviceType(UniformDeviceType.ZIGBEE_FreshAirManager);
            EventBus.getDefault().post(event);
        } else if (statusChangedPushEvent.getDevType() == SHDeviceType.ZIGBEE_FreshAirDev) {
            FreshAirDevStatusEvent event = new FreshAirDevStatusEvent(ccuId, statusChangedPushEvent.getId(), statusChangedPushEvent.getRoomId());
            event.setOnlineState(((ZigbeeDeviceStatus) statusChangedPushEvent.getStatus()).getOnlineState());
            event.setDeviceType(UniformDeviceType.ZIGBEE_FreshAirDev);
            event.setStatus((ZigbeeFreshAirDevStatus) statusChangedPushEvent.getStatus());
            EventBus.getDefault().post(event);
        }
    }

    static void dispatchDooyaOptPushEvent(DooyaOptEvent dooyaOptEvent, String ccuId) {
        EventBus.getDefault().post(new DooyaOptPushEvent(ccuId, dooyaOptEvent.getId(), dooyaOptEvent.getOpt().name()));
    }

    static void dispatchLockSwitchPushEvent(LockSwitchPushEvent lockSwitchPushEvent, String ccuId) {
        EventBus.getDefault().post(new KonkeLockSwitchPushEvent(ccuId, lockSwitchPushEvent.getId(), lockSwitchPushEvent.isOn()));
    }

    static void dispatchOpenLockUserPushEvent(OpenLockUserPushEvent openLockUserPushEvent, String ccuId) {
        XLog.f("usrid" + openLockUserPushEvent.getUserId() + "  deviceId" + openLockUserPushEvent.getId());
        KonkeLockUserOpenPushEvent event = new KonkeLockUserOpenPushEvent(ccuId, openLockUserPushEvent.getId());
        event.setNickName(openLockUserPushEvent.getNickName());
        event.setOpenType(openLockUserPushEvent.getOpenType());
        event.setUserId(openLockUserPushEvent.getUserId());
        EventBus.getDefault().post(event);
    }

    static void dispatchArmingStatusChangedPushEvent(ArmingStateChangedEvent armingStateChangedEvent, String ccuId) {
        EventBus.getDefault().post(new HostArmingChangedEvent(ccuId, armingStateChangedEvent.getState()));
    }

    static void dispatchKonkeLockRemoteOpenDisablePushEvent(LockRemoteOpenDisableEvent event, String ccuId) {
        EventBus.getDefault().post(new KonkeLockRemoteOpenDisablePushEvent(ccuId, event.getId()));
    }

    static void dispatchYaleLockIndoorForeceLockPushEvent(YaleLockIndoorForceLockEvent event, String ccuId) {
        EventBus.getDefault().post(new YaleLockIndoorForeceLockPushEvent(ccuId, event.getId()));
    }

    static void dispatchShortcutPanelActivedEvent(ShortcutPanelActivedEvent shortcutPanelActivedEvent, String ccuId) {
        EventBus.getDefault().post(new ShortcutPanelEvent(ccuId, shortcutPanelActivedEvent.getId(), shortcutPanelActivedEvent.getButtonId()));
    }

    public static void dispatchSycnPushEvent(String ccuId) {
        EventBus.getDefault().post(new CcuInfoChangedEvent(ccuId));
    }

    static synchronized void dispatchAlarmNotifyEvent(AlarmNotifyEvent alarmNotifyEvent, String ccuId) {
        EventBus.getDefault().post(new AlarmStatusEvent(ccuId, alarmNotifyEvent.getKey(), alarmNotifyEvent.getMsg(), Integer.parseInt(alarmNotifyEvent.getNodeId())));
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    static void dispatchBoolSensorActivedEvent(BoolSensorActivedEvent boolSensorActivedEvent, String ccuId) {
        if (boolSensorActivedEvent.isActive())
            EventBus.getDefault().post(new ZigbeeDevIdentifyEvent(ccuId, boolSensorActivedEvent.getId()));

    }

    static void dispatchIdentifyPushEvent(IdentifyPushEvent identifyPushEvent, String ccuId) {
        EventBus.getDefault().post(new ZigbeeDevIdentifyEvent(ccuId, identifyPushEvent.getId()));
    }

    static void dispatchCodeLibUploadResultPushEvent(CodeLibUploadResultPushEvent event, String ccuId) {
        EventBus.getDefault().post(new CodelibUploadResultEvent(ccuId, event.getDevId(), event.getCodeLibId(), event.isSuccess()));
    }

    static void dispatchMatchCloudCodelibResultPushEvent(MatchCloudCodelibResultPushEvent event, String ccuId) {
        EventBus.getDefault().post(new MatchCodelibResultEvent(ccuId, event.getDevId(), event.getDevType(), event.getCodelibs(), event.getErrorCode()));
    }

    static void dispatchCreateNewCodeLibPushEvent(CreateNewCodeLibPushEvent event, String ccuId) {
        EventBus.getDefault().post(new CodelibCreateResultEvent(ccuId, event.getId(), event.getCodelibId(), event.getErrorCode()));
    }

    static void dispatchControllerSmartSwitchPushEvent(ControllerSmartSwitchPushEvent event, String ccuId) {
        EventBus.getDefault().post(new SmartSwitchResultEvent(ccuId, event.getId(), event.isOn(), event.isSuccess()));
    }

    static void dispatchDetectDevPowerResultPushEvent(DetectDevPowerResultPushEvent event, String ccuId) {
        EventBus.getDefault().post(new DetectDevPowerResultEvent(ccuId, event.getId(), event.isStandBy(), event.isRunning(), event.isSuccess()));
    }

    static void dispatchSmartSwitchPushEvent(SmartSwitchPushEvent event, String ccuId) {
        EventBus.getDefault().post(new SmartSwitchStatusEvent(ccuId, event.getId(), event.isOn(), event.getStatus()));
    }

    static void dispatchNewDevicePushEvent(String ccuId) {
        EventBus.getDefault().post(new HostNewDeviceEvent(ccuId));
    }

    public static void dispatchInfraredPushEvent(InfraredPushEvent event, String ccuId) {
        EventBus.getDefault().post(new InfraredRecEvent(ccuId, event.getNodeId(), event.getCode(), event.isSuccess()));
    }

    public static void dispatchRFPushEvent(RFLearnPushEvent event, String ccuId) {
        EventBus.getDefault().post(new RFLearnRecEvent(ccuId, event.getNodeId(), event.getCode(), event.isSuccess()));
    }

    public static void dispatchGwUpgradResultEvent(GwUpgradeResultPushEvent event, String ccuId) {
        EventBus.getDefault().post(new GwUpgradResultEvent(ccuId, event.getId(), event.isSuccess()));
    }

    public static void dispatchRoomStateChangedEvent(RoomStateChangedEvent event, String ccuId) {
        EventBus.getDefault().post(new RoomStatusChangedEvent(ccuId, event.getRoomId()));
    }

    public static void dispatchDeviceAppArgsChangedPushEvent(DeviceAppArgsChangedPushEvent event, String ccuId) {
        UniformDeviceType deviceType = UniformDeviceType.transform(event.getDevType(), event.getDevSubType());
        EventBus.getDefault().post(new DeviceAppArgsChangedEvent(ccuId, event.getId(), deviceType));
    }

    public static void dispatchKitInstallStatusPushEvent(KitInstallStatusPushEvent event, String ccuId) {
        EventBus.getDefault().post(new KitInstallEvent(ccuId, event.getStatus()));
    }

    public static void dispatchZigbeeDeviceJoinEvent(ZigbeeDeviceJoinEvent event, String ccuId) {
        EventBus.getDefault().post(new ZigbeeDeviceJoinChangeEvent(ccuId, event.getMac(), event.getProductId()));
    }

    public static void dispatchCodedLockReadCardPushEvent(CodedLockReadCardPushEvent event, String ccuId) {
        EventBus.getDefault().post(new CodedLockReadCardPushChangeEvent(ccuId, event.getId(), event.getKey(), event.isEncrypt(), event.getKeyId()));
    }

    public static void dispatchCodedLockAlarmPushEvent(CodedLockAlarmPushEvent event, String ccuId) {
        EventBus.getDefault().post(new CodedLockAlarmChangePushEvent(ccuId, event.getDevId(), event.getAlarmType(), event.getAlarmData(), event.getAlarmInWeek(), event.getAlarmInTime()));
    }

    public static void dispatchZigbeeRepalceEvent(ZigbeeNodeReplacePushEvent event, String ccuId) {
        EventBus.getDefault().post(new ZigbeeDeviceReplaceEvent(ccuId, event.getNewDevMac(), event.getOldDevMac(), event.getGwMac(), event.getStatus(), event.isSuccess()));
    }

    public static void dispatchGetZigbeeDevsHwInfoPushEvent(GetZigbeeDevsHwInfoPushEvent event, String s) {
        EventBus.getDefault().post(new ZigbeeDevsHwInfoPushEvent(s));
    }

    public static void dispatchMatchCloudCodelibPushEvent(MatchCodeLibPushEvent event, String s) {
        EventBus.getDefault().post(event);
    }

    public static void dispatchFloorheatingDevTempEvent(FloorheatingDevTempEvent event, String s) {
//        EventBus.getDefault().post(new FlootHeatDevTempEvent(s, event.getDeviceId(), event.getSetTemp()));
    }

    public static void dispatchFancoilConfigArg(FancoilConfigArgEvent event, String s) {
        boolean lock = event.getLock_status().isModel_lock()
                || event.getLock_status().isTime_lock()
                || event.getLock_status().isSwitch_lock()
                || event.getLock_status().isSpeed_lock()
                || event.getLock_status().isRotate_lock();
        EventBus.getDefault().post(new FancoilConfigArgPushEvent(s, event.getDeviceId(), lock,event.getSystem_type()));
    }

    public static void dispatchFloorheatingConfigArg(FloorheatingConfigArgEvent event, String s) {
        boolean lock = event.getLock_status().isModel_lock()
                || event.getLock_status().isTime_lock()
                || event.getLock_status().isSwitch_lock()
                || event.getLock_status().isChild_lock()
                || event.getLock_status().isRotate_lock();
        EventBus.getDefault().post(new FloorheatingConfigArgPushEvent(s, event.getDeviceId(), lock));
    }

    public static void dispatchFreshAirConfigArg(FreshAirConfigArgEvent event, String s) {
        boolean lock = event.getLock_status().isModel_lock()
                || event.getLock_status().isTime_lock()
                || event.getLock_status().isSwitch_lock()
                || event.getLock_status().isChild_lock()
                || event.getLock_status().isRotate_lock();
        EventBus.getDefault().post(new FreshAirConfigArgPushEvent(s, event.getDeviceId(), lock));
    }
}
